package org.linlinjava.litemall.db.service;

 
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.linlinjava.litemall.db.dao.LumiereSubscribeUserOrderMapper;
import org.linlinjava.litemall.db.dao.SubscribeOrderMapper;
import org.linlinjava.litemall.db.dao.SubscribeUserOrderMapper;
import org.linlinjava.litemall.db.domain.LumiereSubscribeUserExample;
import org.linlinjava.litemall.db.domain.LumiereSubscribeUserOrder;
import org.linlinjava.litemall.db.domain.LumiereSubscribeUserOrderExample;
import org.linlinjava.litemall.db.dto.LitemallOrderDto;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class LumiereSubscribeUserOrderService extends MPJBaseServiceImpl<LumiereSubscribeUserOrderMapper,LumiereSubscribeUserOrder> {
    @Resource
    private LumiereSubscribeUserOrderMapper lumiereSubscribeUserOrderMapper;

    @Resource
    private SubscribeOrderMapper subscribeOrderMapper;

    public List<LitemallOrderDto> getUserLogByConditions( String name,  String orderSn,  Integer shopId, String userName,
                                                          String goodsName, Byte orderType,  Short status,
                                                          String subscribeName,
                                                          Integer page,
                                                         Integer limit){
        if(page != null && limit != null){
            //PageHelper.startPage(page,limit);
        }
        return subscribeOrderMapper.getUserLogByConditions(name, orderSn, shopId, userName, goodsName, orderType, status, subscribeName);
    }

    public void add(LumiereSubscribeUserOrder lumiereSubscribeUserOrder){
        lumiereSubscribeUserOrderMapper.insert(lumiereSubscribeUserOrder);
    }

    public List<LumiereSubscribeUserOrder> queryNotConfirm(){
        LumiereSubscribeUserOrderExample example = new LumiereSubscribeUserOrderExample();
        example.createCriteria().andStatusEqualTo((byte) 1);
        return lumiereSubscribeUserOrderMapper.selectByExample(example);
    }

    public void update(LumiereSubscribeUserOrder lumiereSubscribeUserOrder){
        lumiereSubscribeUserOrderMapper.updateByPrimaryKey(lumiereSubscribeUserOrder);
    }

    public List<LumiereSubscribeUserOrder> queryBySubscribeUserId(Integer subscribeUserId){
        LumiereSubscribeUserOrderExample example = new LumiereSubscribeUserOrderExample();
        example.createCriteria().andDeletedEqualTo(false).andSubscribeUserIdEqualTo(subscribeUserId);
        return lumiereSubscribeUserOrderMapper.selectByExample(example);
    }

    public LumiereSubscribeUserOrder findById(Integer userOrderId){
        return lumiereSubscribeUserOrderMapper.selectByPrimaryKey(userOrderId);
    }

    public List<LumiereSubscribeUserOrder> queryAll(){
        LumiereSubscribeUserOrderExample example = new LumiereSubscribeUserOrderExample();
        example.or().andDeletedEqualTo(false);
        return lumiereSubscribeUserOrderMapper.selectByExample(example);
    }

    public List<LumiereSubscribeUserOrder> queryByCondition(Integer page,Integer limit,String sort,String order,Short status){
        LumiereSubscribeUserOrderExample example = new LumiereSubscribeUserOrderExample();
        example.or().andDeletedEqualTo(false);
        return lumiereSubscribeUserOrderMapper.selectByExample(example);
    }

    public Integer countByUserIdNotConfirm(Integer userId,Short status){
//        LumiereSubscribeUserOrderExample example = new LumiereSubscribeUserOrderExample();
//        LumiereSubscribeUserOrderExample.Criteria criteria = example.createCriteria();
//
//        if(userId != null){
//
//        }
        return null;
    }


}
